from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import StringField, TextAreaField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length

class PostForm(FlaskForm):
    title = StringField('标题', validators=[DataRequired('标题不能为空')])
    body = TextAreaField('内容', validators=[DataRequired('内容不能为空')])
    published = BooleanField('发布')
    tags = StringField('标签(用逗号分隔)')
    submit = SubmitField('保存')

class TagForm(FlaskForm):
    name = StringField('标签名称', validators=[
        DataRequired('标签名称不能为空'),
        Length(max=50, message='标签名称不能超过50个字符')
    ])
    submit = SubmitField('保存')

class UploadForm(FlaskForm):
    file = FileField('选择文件', validators=[
        FileRequired('请选择要上传的文件')
    ])
    submit = SubmitField('上传')